In [1]:
# a szokásos rutinok betöltése
%pylab inline
from scipy.integrate import * # az integráló rutinok betöltése
import matplotlib.pyplot as plt

from sympy.functions.special.delta_functions import Heaviside
import sympy


from IPython.core.display import HTML
Populating the interactive namespace from numpy and matplotlib
In [2]:
HTML('''<script>
code_show=true;
function code_toggle() {
 if (code_show){
 $('div.input').hide();
 } else {
 $('div.input').show();
 }
 code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit"
value="Click here to toggle on/off the raw code."></form>''')
Out[2]:
In [3]:
## Warning is ignored!!!!!  Integration may be not too good..... 
In [4]:
import warnings
warnings.filterwarnings("ignore")
In [5]:
(t)=sympy.symbols('t')
In [6]:
def idgaz_eta(VV,pp,gamma,Npont):
    
    #  idealis gazra 
    
    # hatasfok szamolasa
    
    WW=pp * sympy.diff(VV,t)
    qq=1/(gamma-1)*(VV*sympy.diff(pp,t)+gamma*pp*sympy.diff(VV,t))
    q2= qq * Heaviside(qq)
    
    Vn = lambda y:VV.subs({t:y}).n()
    pn = lambda y:pp.subs({t:y}).n()
    
    qn = lambda y:qq.subs({t:y}).n()
    q2n = lambda y:q2.subs({t:y}).n()
    
    WWn = lambda y:WW.subs({t:y}).n()
    
    Qfel= quad(q2n,0,2*np.pi)
    munka= quad(WWn,0,2*np.pi)
    qpm=quad(qn,0,2*np.pi)
    check = munka[0] - qpm[0] 
    
    eta=munka[0]/Qfel[0]
    
    # adatok szamolasa az abrakhoz 
    fi=np.linspace(0,2*np.pi,Npont)
    x = []
    y = []
    qfi = []
    Thom = []
    Sentropia = []
    for i in range(len(fi)):
        fii=fi[i]
        x.append(Vn(fii))          
        y.append(pn(fii))
        qfi.append(qn(fii))
        Thom.append(Vn(fii)*pn(fii))
        Sentropia.append(np.log(float(Vn(fii)*pn(fii)*Vn(fii))))

    
    plt.figure(figsize=(20,6))
      
    #vonalv = 4.0 #  vonal vastagsag
    #dashv = '--'  # '-' -> solid, '--' -> szaggatott  
        
    # korfolyamat rajzolasa 
    plt.subplot(1,3,1,aspect='equal')

    xmax=1.2*np.max(x)   
    ymax=1.2*np.max(y)
    
    #type of xmax, ymax is string, must be converted to decimal !!!
    plt.xlim(0,np.float(xmax))
    plt.ylim(0,np.float(ymax))
    plt.xlabel('V',fontsize=20)
    plt.ylabel('p',fontsize=20)
    
    #plt.plot(x,y,'r-',lw=3)
    
    s=1
    for i in range(0,Npont-s,s):
        #print(qn(fi[i]))
        
        if qn(fi[i]) > 0:
            plt.plot(x[i:i+s+1],y[i:i+s+1],'r-',lw=3)
        else:
            plt.plot(x[i:i+s+1],y[i:i+s+1],'b--',lw=3)
            
    # dQ/dt kirajzolas t fuggvenyeben         
    plt.subplot(1,3,2)
    
    plt.plot(fi,qfi)
    
    plt.xlim(0,2*np.pi)
    plt.ylim(np.float(np.min(qfi)),np.float(np.max(qfi)))
    plt.xlabel('t',fontsize=20)
    plt.ylabel('dQ(t)/dt',fontsize=20)
    plt.axis('on')
    
    # (T,S) gorbe kirajzolasa 
    plt.subplot(1,3,3)
    
    plt.plot(Sentropia,Thom)
    
    plt.xlim(np.float(np.min(Sentropia)),np.float(np.max(Sentropia)))
    plt.ylim(np.float(np.min(Thom)),np.float(np.max(Thom)))
    plt.xlabel('S',fontsize=20)
    plt.ylabel('T',fontsize=20)
    
    
    
    return (eta,munka,Qfel,check)

Körfolyamatok hatásfoka ideális gázra

($\gamma = \frac{c_p}{c_V} = 5/3$)

A p-V síkon a körfolyamatban a piros (folytonos) vonal hőfelvételt, a kék (szaggatott) vonal hőleadást jelent.

Kör alakú körfolyamat

In [7]:
#   kor
gamma = 5 / 3;               # gamma = cp/cV 
V = 2.27 + 1 * sympy.sin(t)
p = 2.27 + 1 * sympy.cos(t)

Npoints = 100

res=idgaz_eta(V,p,gamma,Npoints)

print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
hatásfok =  0.2116
W =  3.142
Qfel =  14.846
check: Qfel- Qle-W =  0.0000000

Kör alakú körfolyamat, határeset

In [8]:
#   kor
gamma = 5 / 3;               # gamma = cp/cV 
V = 1.02 + 1 * sympy.sin(t)
p = 1.02 + 1 * sympy.cos(t)

Npoints = 100

res=idgaz_eta(V,p,gamma,Npoints)

print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
hatásfok =  0.4037
W =  3.142
Qfel =  7.782
check: Qfel- Qle-W =  0.0000000
In [9]:
#   Cycloid of Ceva
gamma = 5 / 3;               # gamma = cp/cV 
V = 4 + (1 + 2*sympy.cos(2*t))*sympy.cos(t)
p = 3 - (1 + 2*sympy.cos(2*t))*sympy.sin(t)

Npoints = 100

res=idgaz_eta(V,p,gamma,Npoints)

print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
hatásfok =  0.1397
W =  9.425
Qfel =  67.470
check: Qfel- Qle-W =  -0.0000000
In [10]:
#   rose
n=3 
gamma = 5 / 3;               # gamma = cp/cV 
V = 2 + 2* sympy.cos(n*t)* sympy.cos(t)
p = 3 - 2* sympy.cos(n*t)*sympy.sin(t)

Npoints = 100

res=idgaz_eta(V,p,gamma,Npoints)

print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
hatásfok =  0.0887
W =  6.283
Qfel =  70.844
check: Qfel- Qle-W =  -0.0000000
In [11]:
#   rose
n=5 
gamma = 5 / 3;               # gamma = cp/cV 
V = 2 + 2* sympy.cos(n*t)* sympy.cos(t)
p = 3 - 2* sympy.cos(n*t)*sympy.sin(t)

Npoints = 100

res=idgaz_eta(V,p,gamma,Npoints)

print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
hatásfok =  0.0536
W =  6.283
Qfel =  117.331
check: Qfel- Qle-W =  0.0000000
In [12]:
#   
gamma = 5 / 3;               # gamma = cp/cV 
V = 3/2 +  sympy.cos(t)**3
p = 3/2 -  sympy.sin(t)**3 

Npoints = 100

res=idgaz_eta(V,p,gamma,Npoints)

print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
hatásfok =  0.1332
W =  1.178
Qfel =  8.845
check: Qfel- Qle-W =  0.0000000
In [13]:
#    nephroid
gamma = 5 / 3;               # gamma = cp/cV 
V = 5 + (3 * sympy.sin(t) - sympy.sin(3*t))
p = 5 + (3 * sympy.cos(t) - sympy.cos(3*t))

Npoints = 100

res=idgaz_eta(V,p,gamma,Npoints)

print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
hatásfok =  0.2787
W =  37.699
Qfel =  135.268
check: Qfel- Qle-W =  0.0000000
In [14]:
#    szivgorbe
gamma = 5 / 3;               # gamma = cp/cV 
V = 20 + 16 * (sympy.sin(t))**3
p = 20 + 13 * sympy.cos(t) - 5*sympy.cos(2*t) - 2*sympy.cos(3*t) - sympy.cos(4*t)

Npoints = 100

res=idgaz_eta(V,p,gamma,Npoints)

print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
hatásfok =  0.2376
W =  565.487
Qfel =  2379.951
check: Qfel- Qle-W =  0.0000000

Saját

In [15]:
#    sajat
gamma = 5 / 3;               # gamma = cp/cV 
V = 5 + (3 * sympy.sin(t) - sympy.sin(3*t))
p = 5 + (3 * sympy.cos(t) - sympy.sin(3*t))

Npoints = 50

res=idgaz_eta(V,p,gamma,Npoints)

print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
hatásfok =  0.1864
W =  28.274
Qfel =  151.714
check: Qfel- Qle-W =  0.0000000
In [ ]: